package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.entity.Role;
import com.three.service.RoleService;
import com.three.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    //查询所有职位
    @GetMapping("/getAll")
    @LogAnotation("查询所有职位")
    public R getAll(){
        return roleService.getAll();
    }
    //分页·
    @GetMapping("/selectByPage")
    public R getAllByPage(Integer currentPage, Integer pageSize){
        return roleService.selectByPage(currentPage,pageSize);
    }

    //添加角色
    @PostMapping("/add")
    @LogAnotation("添加角色")
    public R addRole(@RequestBody Role role){
        return roleService.addRole(role);
    }

    //根据角色id查询角色信息
    @GetMapping("/getByRoleId")
    public R getByRoleId(Integer roleid){
        return roleService.getByRoleId(roleid);
    }
    //修改角色信息
    @PostMapping("/update")
    @LogAnotation("修改角色信息")
    public R updateRole(@RequestBody Role role){
        return roleService.updateRole(role);
    }
    //删除角色
    @DeleteMapping("/delete")
    @LogAnotation("删除角色")
    public R deleteRole(Integer roleid){
        return roleService.deleteRole(roleid);
    }

    //加载所有职位角色
    @GetMapping("/roleAll")
    @LogAnotation("查找所有正常状态下的角色")
    public R roleAll(){
        return roleService.roleAll();
    }
}
